package com.spring.el;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component("itemBean")
public class Item {
	@Value("itemA") //inject String directly
	private String name;

	@Value("10") //inject interger directly
	private int qty;
	
	@Value("#{1 * 1}")
	private double calcValue;
	
	@Value("#{1 == 1}") 
	private boolean testAdd;
	
	@Value("#{'1' + '@' + '1'}") //1@1
	private String testAddString;

	@Value("#{'100' matches '\\d+' }")
	private boolean isDigit;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getQty() {
		return qty;
	}

	public void setQty(int qty) {
		this.qty = qty;
	}
	
	public double getCalcValue() {
		return calcValue;
	}

	public void setCalcValue(double calcValue) {
		this.calcValue = calcValue;
	}
	
	public boolean isTestAdd() {
		return testAdd;
	}

	public void setTestAdd(boolean testAdd) {
		this.testAdd = testAdd;
	}

	public String getTestAddString() {
		return testAddString;
	}

	public void setTestAddString(String testAddString) {
		this.testAddString = testAddString;
	}
	
	public boolean isDigit() {
		return isDigit;
	}

	public void setDigit(boolean isDigit) {
		this.isDigit = isDigit;
	}

	public String getFull(String prefix) {
		return prefix + " : " + name + " " + qty;
	}

	@Override
	public String toString() {
		return "Item [name=" + name + ", qty=" + qty + ", calcValue=" + calcValue + ", testAdd=" + testAdd
				+ ", testAddString=" + testAddString + ", isDigit=" + isDigit + "]";
	}

}
